package controller;



import gui.catalogues.telephones.dto.TelephoneTypesDTO;

import java.sql.SQLException;
import java.util.List;

import model.DatabaseCommons;
import model.TelephoneTypes;
import model.TelephoneTypesDAO;

public class TelephoneTypesController {
	// DummyDB db = new DummyDB();
//	PersonDAO db = new PersonDAO();
	TelephoneTypesDAO db = new TelephoneTypesDAO();
	DatabaseCommons dbc = new DatabaseCommons();

	public List<TelephoneTypes> getElementsList() {
		return db.getElements();
	}

	public void addElement(TelephoneTypesDTO e) {
		TelephoneTypes element = new TelephoneTypes(e.getIdType(), e.getDesc());
		
		db.addElement(element);
	}

	public void removeElement(int index) {
		db.removeElement(index);
	}
	
	public void connectToDB() throws SQLException {
		dbc.h2Connect();
	}

	public void saveToDB() throws SQLException {
		db.saveToDB();
	}

	public void loadFromDB() throws SQLException {
		db.loadFromDB();
	}

	public void disconnectFromDB() throws SQLException {
		dbc.disconnect();
	}
}
